package com.hashnode.springboot_0001_quickstart.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//Rest模式
@RestController
@RequestMapping("/book")
public class BookController {

    //读取yml中的数据
    @Value("${test.country}")
    private String country;

    //读取yml中的数据
    @Value("${test.user.sex}")
    private String name;

    //读取yml中的数据
    @Value("${test.likes[1]}")
    private String likes1;


    //读取yml中的数据
//    @Value("${users[0].name}")
    @Value("${test.users2[0].name}")
    private String username;

    @Autowired
    ReadTest readTest;

    @GetMapping("/")
    public String getById(){
        System.out.println("springboot is running");
//        System.out.println(country);
//        System.out.println(name);
//        System.out.println(likes1);
//        System.out.println(username);
        System.out.println(readTest);
        return "springboot is running";
    }
}
